package com.junzhiit.nengji.cms.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.bainaeco.framework.util.AssertUtil;
import com.junzhiit.nengji.cms.service.ShopInfoService;
import com.junzhiit.nengji.cms.web.vo.ResultVO;
import com.junzhiit.nengji.cms.web.vo.ShopInfoEditVO;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/shop/info")
public class ShopInfoController extends BaseController{
	
	@Autowired
	private ShopInfoService shopInfoService;
	
	@ApiOperation(value = "获取商户营业信息")
	@RequestMapping(method=RequestMethod.GET)
	public ResultVO findBySessionId(String sessionId){
		return shopInfoService.findBySessionId(sessionId);
	}
	
	@ApiOperation(value = "更新商户营业信息")
	@RequestMapping(method = RequestMethod.PUT)
	public ResultVO update(ShopInfoEditVO shopInfoEditVO) {
		AssertUtil.notBlank(shopInfoEditVO.getId(), "id is required");
		return shopInfoService.update(shopInfoEditVO);
	}
	
	@RequestMapping(method=RequestMethod.DELETE)
	public ResultVO delShopInfoImg(Integer imgType,String id){
		return shopInfoService.delShopInfoImg(imgType,id);
	}
	
	@RequestMapping(value="/shopid/{shopId}",method=RequestMethod.GET)
	public ResultVO findByShopId(@PathVariable String shopId){
		return shopInfoService.findByShopId(shopId);
	}
}
